package com.demo1;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class C3p0Test1 {
    public static void main(String[] args) throws Exception {
        //1.创建3cp0数据库连接池对象
        DataSource dataSource = new ComboPooledDataSource();
        //2.获取数据库连接
        Connection conn = dataSource.getConnection();
        //3.执行
        PreparedStatement ps = conn.prepareStatement("select * from stu");

        ResultSet rs = ps.executeQuery();
        while (rs.next()){
            System.out.println(rs.getInt("id")+rs.getString("name")
            +rs.getString("password"));
        }
        rs.close();
        ps.close();
        conn.close();

    }
}
